<?php
namespace BP\Web;
// require_once("java/io/UnsupportedEncodingException.php");
// require_once("java/net/URLDecoder.php");
// require_once("java/net/URLEncoder.php");
// require_once("java/text/SimpleDateFormat.php");
// require_once("java/util/Date.php");
// require_once("javax/servlet/http/Cookie.php");
// require_once("javax/sound/sampled/Port.php");
// require_once("org/apache/commons/lang/ObjectUtils.php");
// require_once("org/apache/commons/lang/StringUtils.php");
// require_once("BP/DA/DBAccess.php");
// require_once("BP/DA/DataType.php");
// require_once("BP/DA/Paras.php");
// require_once("BP/Difference/ContextHolderUtils.php");
// require_once("BP/En/QueryObject.php");
// require_once("BP/Port/Current.php");
// require_once("BP/Port/Emp.php");
// require_once("BP/Port/Stations.php");
// require_once("BP/Sys/OSDBSrc.php");
// require_once("BP/Sys/OSModel.php");
// require_once("BP/Sys/SystemConfig.php");
// require_once("BP/Tools/StringHelper.php");
// require_once("BP/WF/Dev2Interface.php");
use BP\DA\DBAccess;
use BP\Port\Dept;
use BP\Port\Stations;
use BP\Sys\Glo;
use BP\Sys\SystemConfig;
use BP\DA\Paras;

class WebUser {
	public static function SignInOfGener_Emp ($em) // [Emp em]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, "CH", NULL,  TRUE ,  FALSE );
	}
	public static function SignInOfGener_Emp_b ($em, $isRememberMe) // [Emp em, boolean isRememberMe]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, "CH", NULL, $isRememberMe,  FALSE );
	}
	public static function SignInOfGenerAuth ($em, $auth) // [Emp em, String auth]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, "CH", $auth,  TRUE ,  FALSE );
	}
	public static function SignInOfGenerLang_Emp_String_b ($em, $lang, $isRememberMe) // [Emp em, String lang, boolean isRememberMe]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, $lang, NULL, $isRememberMe,  FALSE );
	}
	public static function SignInOfGenerLang_Emp_String ($em, $lang) // [Emp em, String lang]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, $lang, NULL,  TRUE ,  FALSE );
	}
	public static function SignInOfGener_Emp_String ($em, $lang) // [Emp em, String lang]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, $lang, $em->getNo(),  TRUE ,  FALSE );
	}
	public static function SignInOfGener_Emp_String_String_b ($em, $lang, $auth, $isRememberMe) // [Emp em, String lang, String auth, boolean isRememberMe]
	{
			/* match: Emp_String_String_b_b */
		WebUser::SignInOfGener_Emp_String_String_b_b($em, $lang, $auth, $isRememberMe,  FALSE );
	}
	public static function SignInOfGener_Emp_String_String_b_b ($em, $lang, $auth, $isRememberMe, $IsRecSID) // [Emp em, String lang, String auth, boolean isRememberMe, boolean IsRecSID]
	{
		if (SystemConfig::getIsBSsystem())
		{
			if ("BP" /* from: "BP".equals(SystemConfig.getRunOnPlant()) */)
			{
				Glo::WriteUserLog("SignIn", $em->getNo(), "登录");
			}
		}
		if (($auth . NULL))
		{
			$auth = "";
		}
		$sid = NULL;
		try 
		{
			WebUser::setNo($em->getNo());
			WebUser::setName($em->getName());
			WebUser::setFK_Dept($em->getFK_Dept());
			WebUser::setFK_DeptName($em->getFK_DeptText());
			try 
			{
				$sid = $ContextHolderUtils->getSession()->getId();
			}
			catch (\Exception $e)
			{
				$sid = (DBAccess::GenerOID() . "");
			}
			if ($IsRecSID)
			{
				WebUser::setSID($sid);
				$Dev2Interface->Port_SetSID($em->getNo(), $sid);
			}
			WebUser::setAuth($auth);
			WebUser::setUserWorkDev(UserWorkDev::$PC);
			WebUser::setSysLang($lang);
			if (SystemConfig::getIsBSsystem())
			{
				try 
				{
					$expiry = (((60 * 60) * 24) * 2);
					$ContextHolderUtils->addCookie("No", $expiry, $em->getNo());
					$ContextHolderUtils->addCookie("Name", $expiry, $URLEncoder->encode($em->getName(), "UTF-8"));
					$ContextHolderUtils->addCookie("IsRememberMe", $expiry, ( ($isRememberMe) ? "1" : "0" ));
					$ContextHolderUtils->addCookie("FK_Dept", $expiry, $em->getFK_Dept());
					$ContextHolderUtils->addCookie("FK_DeptName", $expiry, $URLEncoder->encode($em->getFK_DeptText(), "UTF-8"));
					if (($ContextHolderUtils->getSession() != NULL))
					{
						$ContextHolderUtils->addCookie("Token", $expiry, $sid);
						$ContextHolderUtils->addCookie("SID", $expiry, $sid);
					}
					$ContextHolderUtils->addCookie("Lang", $expiry, $lang);
					$ContextHolderUtils->addCookie("Auth", $expiry, $auth);
				}
				catch (\Exception $e)
				{ /* empty */ }
			}
		}
		catch (\Exception $e)
		{
			$e->printStackTrace();
		}
		return $sid;
	}
	public static function SignInOfGener_Emp_String_b_b_String_String ($em, $lang, $isRememberMe, $IsRecSID, $authNo, $authName) // [Emp em, String lang, boolean isRememberMe, boolean IsRecSID, String authNo, String authName]
	{
		if (SystemConfig::getIsBSsystem())
		{
			Glo::WriteUserLog("SignIn", $em->getNo(), "登录");
		}
		WebUser::setNo($em->getNo());
		WebUser::setName($em->getName());
		if (($DataType->IsNullOrEmpty($authNo) ==  FALSE ))
		{
			WebUser::setAuth($authNo);
			WebUser::setAuthName($authName);
		}
		else
		{
			WebUser::setAuth(NULL);
			WebUser::setAuthName(NULL);
		}
		WebUser::setUserWorkDev(UserWorkDev::$PC);
		if ((SystemConfig::getOSDBSrc() == $OSDBSrc->Database))
		{
			if (($DataType->IsNullOrEmpty($em->getFK_Dept()) ==  TRUE ))
			{
				$sql = "";
				if ((SystemConfig::getOSModel() == $OSModel->OneOne))
				{
					$sql = (("SELECT FK_Dept FROM Port_Emp WHERE No='" . $em->getNo()) . "'");
				}
				else
				{
					$sql = (("SELECT FK_Dept FROM Port_DeptEmp WHERE FK_Emp='" . $em->getNo()) . "'");
				}
				$deptNo = DBAccess::RunSQLReturnString($sql);
				if (($DataType->IsNullOrEmpty($deptNo) ==  TRUE ))
				{
					throw new \RuntimeException((((("@登录人员(" . $em->getNo()) . ",") . $em->getName()) . ")没有维护部门..."));
				}
				else
				{
					WebUser::ChangeMainDept($em->getNo(), $deptNo);
				}
			}
			$dept = new Dept();
			$dept->setNo($em->getFK_Dept());
			if (($dept->RetrieveFromDBSources() == 0))
			{
				throw new \RuntimeException((((((("@登录人员(" . $em->getNo()) . ",") . $em->getName()) . ")没有维护部门,或�?�部门编号{") . $em->getFK_Dept()) . "}不存�?."));
			}
		}
		if ((SystemConfig::getOSDBSrc() == $OSDBSrc->WebServices))
		WebUser::setFK_Dept($em->getFK_Dept());
		WebUser::setFK_DeptName($em->getFK_DeptText());
		WebUser::setHisDeptsStr(NULL);
		WebUser::setHisStationsStr(NULL);
		if ($IsRecSID)
		{
			if ((DBAccess::IsView("Port_Emp") ==  FALSE ))
			{
// 				$formatter = new SimpleDateFormat("MMddHHmmss");
// 				$sid1 = $formatter->format(new Date());
				$sid1 = date('mdHis', time());
				DBAccess::RunSQL((((("UPDATE Port_Emp SET SID='" . $sid1) . "' WHERE No='") . WebUser::getNo()) . "'"));
				WebUser::setSID($sid1);
			}
		}
		WebUser::setSysLang($lang);
		if (SystemConfig::getIsBSsystem())
		{
			$hc = $ContextHolderUtils->getCookie("CCS");
			if (($hc != NULL))
			{
				$ContextHolderUtils->deleteCookie("CCS");
			}
			$expiry = (((60 * 60) * 24) * 2);
			$ContextHolderUtils->addCookie("No", $expiry, $em->getNo());
			$ContextHolderUtils->addCookie("Name", $expiry, $URLEncoder->encode($em->getName(), "UTF-8"));
			if ($isRememberMe)
			{
				$ContextHolderUtils->addCookie("IsRememberMe", $expiry, "1");
			}
			else
			{
				$ContextHolderUtils->addCookie("IsRememberMe", $expiry, "0");
			}
			$ContextHolderUtils->addCookie("FK_Dept", $expiry, $em->getFK_Dept());
			$ContextHolderUtils->addCookie("FK_DeptName", $expiry, $URLEncoder->encode($em->getFK_DeptText(), "UTF-8"));
			if (($ContextHolderUtils->getSession() != NULL))
			{
				$ContextHolderUtils->addCookie("Token", $expiry, WebUser::getNoOfSessionID());
				$ContextHolderUtils->addCookie("SID", $expiry, WebUser::getNoOfSessionID());
			}
			$ContextHolderUtils->addCookie("Lang", $expiry, $lang);
			if (($authNo . NULL))
			{
				$authNo = "";
			}
			$ContextHolderUtils->addCookie("Auth", $expiry, $authNo);
			if (($authName . NULL))
			{
				$authName = "";
			}
			$ContextHolderUtils->addCookie("AuthName", $expiry, $URLEncoder->encode($authName, "UTF-8"));
		}
	}
	protected static function ChangeMainDept ($no, $deptNo) // [String no, String deptNo]
	{
		$sql = SystemConfig::GetValByKey("UpdataMainDeptSQL", "");
		if ($sql->equals(""))
		{
			$sql = "UPDATE Port_Emp SET FK_Dept=@FK_Dept WHERE No=@No";
		}
		$sql = $sql->replace("@FK_Dept", (("'" . $deptNo) . "'"));
		$sql = $sql->replace("@No", (("'" . $no) . "'"));
		try 
		{
			if (($sql->contains("UPDATE Port_Emp SET FK_Dept=") ==  TRUE ))
				if ((DBAccess::IsView("Port_Emp") ==  TRUE ))
					return ;
			DBAccess::RunSQL($sql);
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException(("@执行更改当前操作员的主部门的时�?�错�?,请检查SQL配置:" . $ex->getMessage()));
		}
	}
	// Exit重命名为FExit
	public static function FExit () 
	{
		try 
		{
			WebUser::setNo(NULL);
			WebUser::setName(NULL);
			WebUser::setFK_Dept(NULL);
			WebUser::setFK_DeptName(NULL);
			WebUser::setSID(NULL);
			WebUser::setAuth(NULL);
			WebUser::setSysLang(NULL);
			if (SystemConfig::getIsBSsystem())
			{
				$expiry = (((60 * 60) * 24) * 2);
				$ContextHolderUtils->addCookie("No", $expiry, NULL);
				$ContextHolderUtils->addCookie("Name", $expiry, NULL);
				$ContextHolderUtils->addCookie("IsRememberMe", $expiry, NULL);
				$ContextHolderUtils->addCookie("FK_Dept", $expiry, NULL);
				$ContextHolderUtils->addCookie("FK_DeptName", $expiry, NULL);
				$ContextHolderUtils->addCookie("Token", $expiry, NULL);
				$ContextHolderUtils->addCookie("SID", $expiry, NULL);
				$ContextHolderUtils->addCookie("Lang", $expiry, NULL);
				$ContextHolderUtils->addCookie("Auth", $expiry, NULL);
			}
		}
		catch (\Exception $e2)
		{ /* empty */ }
	}
	protected static function getIsBSMode () 
	{
		if (($ContextHolderUtils->getRequest() == NULL))
		{
			return  FALSE ;
		}
		else
		{
			return  TRUE ;
		}
	}
	public static function GetSessionByKey_String_String ($key, $isNullAsVal) // [String key, String isNullAsVal]
	{
		if (((WebUser::getIsBSMode() && (NULL != $ContextHolderUtils->getRequest())) && (NULL != $ContextHolderUtils->getSession())))
		{
			$value = $ContextHolderUtils->getSession()->getAttribute($key);
			$str = ( (($value == NULL)) ? "" : $String->valueOf($value) );
			if ($StringHelper->isNullOrEmpty($str))
			{
				$str = $isNullAsVal;
			}
			return $str;
		}
		else
		{
			if ((((($Current->Session->get($key) == NULL) || $Current->Session->get($key)->equals(""))) . ($isNullAsVal . NULL)))
			{
				return $isNullAsVal;
			}
			else
			{
				$str = $Current->Session->get($key);
				return $str;
			}
		}
	}
	public static function GetSessionByKey_String_Object ($key, $defaultObjVal) // [String key, Object defaultObjVal]
	{
		if (((WebUser::getIsBSMode() && (NULL != $ContextHolderUtils->getRequest())) && (NULL != $ContextHolderUtils->getSession())))
		{
			$value = $ContextHolderUtils->getSession()->getAttribute($key);
			if ((NULL == $value))
			{
				return $defaultObjVal;
			}
			else
			{
				return $value;
			}
		}
		else
		{
			if (($Current->Session->get($key) == NULL))
			{
				return $defaultObjVal;
			}
			else
			{
				return $Current->Session->get($key);
			}
		}
	}
	public static function SetSessionByKey ($key, $val) // [String key, Object val]
	{
		if (((WebUser::getIsBSMode() && (NULL != $ContextHolderUtils->getRequest())) && (NULL != $ContextHolderUtils->getSession())))
		{
			$ContextHolderUtils->getSession()->setAttribute($key, $val);
		}
		else
		{
			$Current->SetSession($key, $val);
		}
	}
	public static function GetValFromCookie ($valKey, $isNullAsVal, $isChinese) // [String valKey, String isNullAsVal, boolean isChinese]
	{
		if (!WebUser::getIsBSMode())
		{
			return $Current->GetSessionStr($valKey, $isNullAsVal);
		}
		try 
		{
			$value = $ContextHolderUtils->getSession()->getAttribute($valKey);
			$v = ( (($value == NULL)) ? "" : $String->valueOf($value) );
			if (!$StringHelper->isNullOrEmpty($v))
			{
				if ($isChinese)
				{
					$v = $URLDecoder->decode($v, "UTF-8");
				}
				return $v;
			}
		}
		catch (\Exception $e)
		{ /* empty */ }
		try 
		{
			$val = NULL;
			$cookie = $ContextHolderUtils->getCookie($valKey);
			if (($cookie != NULL))
			{
				if ($isChinese)
				{
					$val = $URLDecoder->decode($cookie->getValue(), "UTF-8");
				}
				else
				{
					$val = $cookie->getValue();
				}
			}
			if ($StringHelper->isNullOrEmpty($val))
			{
				return $isNullAsVal;
			}
			return $val;
		}
		catch (\Exception $e2)
		{
			$e2->printStackTrace();
			return $isNullAsVal;
		}
	}
	public static function getSysLang () 
	{
		return "CH";
	}
	public static function setSysLang ($value) // [String value]
	{
		WebUser::SetSessionByKey("Lang", $value);
	}
	public static function getFK_Dept () 
	{
		$val = WebUser::GetValFromCookie("FK_Dept", NULL,  FALSE );
		if (($val . NULL))
		{
			throw new \RuntimeException("@err-003 FK_Dept 登录信息丢失，请确认当前操作员的部门信息是否完整，检查表:Port_Emp 字段 FK_Dept�?");
		}
		return $val;
	}
	public static function setFK_Dept ($value) // [String value]
	{
		WebUser::SetSessionByKey("FK_Dept", $value);
	}
	public static function getDeptParentNo () 
	{
		$val = WebUser::GetValFromCookie("DeptParentNo", NULL,  FALSE );
		if (($val . NULL))
		{
			if ((WebUser::getFK_Dept() . NULL))
				throw new \RuntimeException("@err-001 DeptParentNo, FK_Dept 登录信息丢失�?");
			$dept = new Dept(WebUser::getFK_Dept());
			WebUser::setDeptParentNo($dept->getParentNo());
			return $dept->getParentNo();
		}
		return $val;
	}
	public static function setDeptParentNo ($value) // [String value]
	{
		WebUser::SetSessionByKey("DeptParentNo", $value);
	}
	public static function CheckSID ($UserNo, $SID) // [String UserNo, String SID]
	{
		return  TRUE ;
	}
	public static function getNoOfSessionID () 
	{
		$s = WebUser::GetSessionByKey_String_String("No", NULL);
		if (($s . NULL))
		{
			return $ContextHolderUtils->getSession()->getId();
		}
		return $s;
	}
	public static function getIsAdmin () 
	{
		if ("admin" /* from: "admin".equals(WebUser.getNo()) */)
			return  TRUE ;
		try 
		{
			$sql = (("SELECT * FROM WF_Emp WHERE UserType=1 AND No='" . WebUser::getNo()) . "'");
			if ((DBAccess::RunSQLReturnTable($sql)->Rows->size() == 1))
				return  TRUE ;
			return  FALSE ;
		}
		catch (\Exception $E)
		{
			return  FALSE ;
		}
	}
	public static function getNoOfRel () 
	{
		return WebUser::GetSessionByKey_String_String("No", NULL);
	}
	public static function getNo () 
	{
// 		$userNoSessionKey = $ContextHolderUtils->getInstance()->getUserNoSessionKey();
// 		if ($StringUtils->isNotBlank($userNoSessionKey))
// 		{
// 			$userNo = $ObjectUtils->toString($ContextHolderUtils->getSession()->getAttribute($userNoSessionKey));
// 			if ($StringUtils->isNotBlank($userNo))
// 			{
// 				if ($BP->WF->Glo->getIsAdmin($userNo))
// 				{
// 					$userNo = "admin";
// 				}
// 				$val = WebUser::GetSessionByKey_String_String("No", "");
// 				if ((($val . NULL) . $userNo->equals($val)))
// 				{
// 					return $val;
// 				}
// 				else
// 				{
// 					$emp = new Emp($userNo);
// 			/* match: Emp_String_String_b_b */
// 					WebUser::SignInOfGener_Emp_String_String_b_b($emp, "CH", NULL,  TRUE ,  TRUE );
// 				}
// 			}
// 			else
// 			{
// 				WebUser::FExit();
// 			}
// 		}
// 		$val = WebUser::GetSessionByKey_String_String("No", "");
// 		if (($val . NULL))
// 		{
// 			throw new \RuntimeException("@err-002 No 登录信息丢失�?");
// 		}
// 		return $val;
	}
	public static function setNo ($value) // [String value]
	{
		WebUser::SetSessionByKey("No", $value->trim());
	}
	public static function getName () 
	{
		$val = WebUser::GetSessionByKey_String_String("Name", "");
		if (($val . NULL))
		{
			throw new \RuntimeException("@err-002 Name 登录信息丢失�?");
		}
		return $val;
	}
	public static function setName ($value) // [String value]
	{
		WebUser::SetSessionByKey("Name", $value);
	}
	public static function getDomain () 
	{
		$val = WebUser::GetSessionByKey_String_String("Domain", "");
		if (($val . NULL))
		{
			throw new \RuntimeException("@err-003 Domain 登录信息丢失�?");
		}
		return $val;
	}
	public static function setDomain ($value) // [String value]
	{
		WebUser::SetSessionByKey("Domain", $value);
	}
	public static function getToken () 
	{
		return WebUser::GetSessionByKey_String_String("token", "null");
	}
	public static function setToken ($value) // [String value]
	{
		WebUser::SetSessionByKey("token", $value);
	}
	public static function getAuth () 
	{
		$val = WebUser::GetValFromCookie("Auth", NULL,  FALSE );
		if (($val . NULL))
		{
			$val = WebUser::GetSessionByKey_String_String("Auth", NULL);
		}
		return $val;
	}
	public static function setAuth ($value) // [String value]
	{
		if ((($value . NULL) . $value->equals("")))
		{
			WebUser::SetSessionByKey("Auth", NULL);
		}
		else
		{
			WebUser::SetSessionByKey("Auth", $value);
		}
	}
	public static function getAuthName () 
	{
		$val = WebUser::GetValFromCookie("AuthName", NULL,  FALSE );
		if (($val . NULL))
		{
			$val = WebUser::GetSessionByKey_String_String("AuthName", NULL);
		}
		return $val;
	}
	public static function setAuthName ($value) // [String value]
	{
		if ((((NULL . $value) . "null" /* from: "null".equals(value) */) . $value->equals("")))
		{
			WebUser::SetSessionByKey("AuthName", NULL);
		}
		else
		{
			WebUser::SetSessionByKey("AuthName", $value);
		}
	}
	public static function getFK_DeptName () 
	{
		try 
		{
			$val = WebUser::GetSessionByKey_String_String("FK_DeptName", "");
			return $val;
		}
		catch (\Exception $e)
		{
			return "�?";
		}
	}
	public static function setFK_DeptName ($value) // [String value]
	{
		WebUser::SetSessionByKey("FK_DeptName", $value);
	}
	public static function getFK_DeptNameOfFull () 
	{
		$val = WebUser::GetValFromCookie("FK_DeptNameOfFull", NULL,  TRUE );
		if ($StringHelper->isNullOrEmpty($val))
		{
			try 
			{
				$val = DBAccess::RunSQLReturnStringIsNull((("SELECT NameOfPath FROM Port_Dept WHERE No='" . WebUser::getFK_Dept()) . "'"), "");
				return $val;
			}
			catch (\Exception $e)
			{
				$val = WebUser::getFK_DeptName();
			}
			WebUser::setFK_DeptNameOfFull($val);
		}
		return $val;
	}
	public static function setFK_DeptNameOfFull ($value) // [String value]
	{
		WebUser::SetSessionByKey("FK_DeptNameOfFull", $value);
	}
	public static function getStyle () 
	{
		return WebUser::GetSessionByKey_String_String("Style", "0");
	}
	public static function setStyle ($value) // [String value]
	{
		WebUser::SetSessionByKey("Style", $value);
	}
	public static function getHisEmp () 
	{
		return new Emp(WebUser::getNo());
	}
	public static function getSID () 
	{
		$val = WebUser::GetValFromCookie("SID", NULL,  TRUE );
		if (($val . NULL))
		{
			return "";
		}
		return $val;
	}
	public static function setSID ($value) // [String value]
	{
		WebUser::SetSessionByKey("SID", $value);
	}
	// SetSID重命名为UpperSetSID
	public static function UpperSetSID ($sid) // [String sid]
	{
		if ((DBAccess::IsView("Port_Emp") ==  FALSE ))
		{
			$ps = new Paras();
			$ps->SQL = (((("UPDATE Port_Emp SET SID=" . SystemConfig::getAppCenterDBVarStr()) . "SID WHERE No=") . SystemConfig::getAppCenterDBVarStr()) . "No");
			$ps->Add("SID", $sid);
			$ps->Add("No", WebUser::getNo());
			DBAccess::RunSQL($ps);
		}
		WebUser::setSID($sid);
	}
	public static function getIsAuthorize () 
	{
		if (((WebUser::getAuth() . NULL) . WebUser::getAuth()->equals("")))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function getAuthorizerEmpID () 
	{
		return WebUser::GetSessionByKey_String_String("AuthorizerEmpID", NULL);
	}
	public static function setAuthorizerEmpID ($value) // [String value]
	{
		WebUser::SetSessionByKey("AuthorizerEmpID", $value);
	}
	public static function getUserWorkDev () 
	{
		if ((SystemConfig::getIsBSsystem() ==  FALSE ))
		{
			return ;
		}
		$s = WebUser::GetSessionByKey("UserWorkDev", 0);
		$wd = UserWorkDev::forValue($s);
		return $wd;
	}
	public static function setUserWorkDev ($value) // [UserWorkDev value]
	{
		WebUser::SetSessionByKey("UserWorkDev", $value->getValue());
	}
	public static function getIsWap () 
	{
		if (!SystemConfig::getIsBSsystem())
			return  FALSE ;
		$s = $Integer->parseInt(WebUser::GetSessionByKey("IsWap", 9));
		if ((9 == $s))
		{
			$userAgent = $ContextHolderUtils->getRequest()->getHeader("USER-AGENT")->toLowerCase();
			$b = $userAgent->contains("wap");
			WebUser::setIsWap($b);
			if ($b)
			{
				WebUser::SetSessionByKey("IsWap", 1);
			}
			else
			{
				WebUser::SetSessionByKey("IsWap", 0);
			}
			return $b;
		}
		if (($s == 1))
			return  TRUE ;
		else
			return  FALSE ;
	}
	public static function setIsWap ($value) // [boolean value]
	{
		if ($value)
		{
			WebUser::SetSessionByKey("IsWap", 1);
		}
		else
		{
			WebUser::SetSessionByKey("IsWap", 0);
		}
	}
	public static function getHisStations () 
	{
		$obj = NULL;
		$obj = WebUser::GetSessionByKey_String_Object("HisSts", $obj);
		if (($obj == NULL))
		{
			$sts = new Stations();
			$qo = new QueryObject($sts);
			$qo->AddWhereInSQL("No", (("SELECT FK_Station FROM Port_EmpStation WHERE FK_Emp='" . WebUser::getNo()) . "'"));
			$qo->DoQuery();
			WebUser::SetSessionByKey("HisSts", $sts);
			return $sts;
		}
		return (( (($obj instanceof Stations)) ? $obj : NULL ));
	}
	public static function getHisStationsStr () 
	{
		$val = WebUser::GetValFromCookie("HisStationsStr", NULL,  TRUE );
		if (($val . NULL))
		{
			$tempVar = DBAccess::RunSQLReturnVal((("SELECT Stas FROM WF_Emp WHERE No='" . WebUser::getNo()) . "'"));
			$val = (( (($tempVar instanceof String)) ? $tempVar : NULL ));
			if (($val . NULL))
			{
				$val = "";
			}
			WebUser::SetSessionByKey("HisStationsStr", $val);
		}
		return $val;
	}
	public static function setHisStationsStr ($value) // [String value]
	{
		WebUser::SetSessionByKey("HisStationsStr", $value);
	}
	public static function getHisDeptsStr () 
	{
		$val = WebUser::GetValFromCookie("HisDeptsStr", "",  TRUE );
		if (($val . NULL))
		{
			$tempVar = DBAccess::RunSQLReturnVal((("SELECT Depts FROM WF_Emp WHERE No='" . WebUser::getNo()) . "'"));
			$val = (( (($tempVar instanceof String)) ? $tempVar : NULL ));
			if (($val . NULL))
			{
				$val = "";
			}
			WebUser::SetSessionByKey("HisDeptsStr", $val);
		}
		return $val;
	}
	public static function setHisDeptsStr ($value) // [String value]
	{
		WebUser::SetSessionByKey("HisDeptsStr", $value);
	}
	public static function SignInOfGener2017_String_String_String_String_String ($userNo, $userName, $deptNo, $deptName, $authNo) // [String userNo, String userName, String deptNo, String deptName, String authNo]
	{
			/* match: String_String_String_String_String_String */
		WebUser::SignInOfGener2017_String_String_String_String_String_String($userNo, $userName, $deptNo, $deptName, $authNo, NULL);
	}
	public static function SignInOfGener2017_String_String_String_String ($userNo, $userName, $deptNo, $deptName) // [String userNo, String userName, String deptNo, String deptName]
	{
			/* match: String_String_String_String_String_String */
		WebUser::SignInOfGener2017_String_String_String_String_String_String($userNo, $userName, $deptNo, $deptName, NULL, NULL);
	}
	public static function SignInOfGener2017_String_String_String ($userNo, $userName, $deptNo) // [String userNo, String userName, String deptNo]
	{
			/* match: String_String_String_String_String_String */
		WebUser::SignInOfGener2017_String_String_String_String_String_String($userNo, $userName, $deptNo, NULL, NULL, NULL);
	}
	public static function SignInOfGener2017_String_String ($userNo, $userName) // [String userNo, String userName]
	{
			/* match: String_String_String_String_String_String */
		WebUser::SignInOfGener2017_String_String_String_String_String_String($userNo, $userName, NULL, NULL, NULL, NULL);
	}
	public static function SignInOfGener2017_String ($userNo) // [String userNo]
	{
			/* match: String_String_String_String_String_String */
		WebUser::SignInOfGener2017_String_String_String_String_String_String($userNo, NULL, NULL, NULL, NULL, NULL);
	}
	public static function SignInOfGener2017_String_String_String_String_String_String ($userNo, $userName, $deptNo, $deptName, $authNo, $authName) // [String userNo, String userName, String deptNo, String deptName, String authNo, String authName]
	{
		if (($ContextHolderUtils->getRequest() == NULL))
		{
			SystemConfig::setIsBSsystem( FALSE );
		}
		else
		{
			SystemConfig::setIsBSsystem( TRUE );
		}
		WebUser::setNo($userNo);
		WebUser::setName($userName);
		if (($DataType->IsNullOrEmpty($authNo) ==  FALSE ))
		{
			WebUser::setAuth($authNo);
			WebUser::setAuthName($authName);
		}
		else
		{
			WebUser::setAuth(NULL);
			WebUser::setAuthName(NULL);
		}
		WebUser::setUserWorkDev(UserWorkDev::$PC);
		if ((SystemConfig::getOSDBSrc() == $OSDBSrc->Database))
		{
			if (($StringHelper->isNullOrEmpty($deptNo) ==  TRUE ))
			{
				$sql = "";
				if ((SystemConfig::getOSModel() == $OSModel->OneOne))
				{
					$sql = (("SELECT FK_Dept FROM Port_EmpDept WHERE FK_Emp='" . $userNo) . "'");
				}
				else
				{
					$sql = (("SELECT FK_Dept FROM Port_DeptEmp WHERE FK_Emp='" . $userNo) . "'");
				}
				$deptNo = DBAccess::RunSQLReturnString($sql);
				if (($StringHelper->isNullOrEmpty($deptNo) ==  TRUE ))
				{
					throw new \RuntimeException((((("@登录人员(" . $userNo) . ",") . $userName) . ")没有维护部门..."));
				}
				else{}
			}
		}
		WebUser::setFK_Dept($deptNo);
		WebUser::setFK_DeptName($deptName);
		WebUser::setHisDeptsStr(NULL);
		WebUser::setHisStationsStr(NULL);
		if (SystemConfig::getIsBSsystem())
		{
			$hc = $ContextHolderUtils->getCookie("CCS");
			if (($hc != NULL))
			{
				$hc = new Cookie("CCS", NULL);
			}
			$expiry = (((60 * 60) * 24) * 2);
			$ContextHolderUtils->addCookie("No", $expiry, $userNo);
			$ContextHolderUtils->addCookie("Name", $expiry, $URLEncoder->encode($userName, "UTF-8"));
			$ContextHolderUtils->addCookie("FK_Dept", $expiry, $deptNo);
			$ContextHolderUtils->addCookie("FK_DeptName", $expiry, $URLEncoder->encode($deptName, "UTF-8"));
			if (($ContextHolderUtils->getSession() != NULL))
			{
				$ContextHolderUtils->addCookie("Token", $expiry, WebUser::getNoOfSessionID());
				$ContextHolderUtils->addCookie("SID", $expiry, WebUser::getNoOfSessionID());
			}
			if (($authNo . NULL))
			{
				$authNo = "";
			}
			$ContextHolderUtils->addCookie("Auth", $expiry, $authNo);
			if (($authName . NULL))
			{
				$authName = "";
			}
			$ContextHolderUtils->addCookie("AuthName", $expiry, $authName);
		}
	}
}
?>
